package com.bluesky.daoImpl;

import java.io.File;
import java.io.IOException;

import org.apache.commons.io.FileUtils;
import org.apache.struts2.ServletActionContext;

import com.bluesky.dao.UpImgtoFile;

public class UpImgTofileImpl implements UpImgtoFile {

	public void UpImgTofiles(String imageFileName, File image) {
		String path = ServletActionContext.getServletContext().getRealPath(
				"/Upimages");
		if (image != null) {
			File savefile = new File(new File(path), imageFileName);
			if (!savefile.getParentFile().exists())
				savefile.getParentFile().mkdirs();
			try {
				FileUtils.copyFile(image, savefile);
			} catch (IOException e) {
				e.printStackTrace();
			}

		}
	}

public void DeleByImageOne(String imageFileName) {
	 String path = ServletActionContext.getServletContext().getRealPath("/Upimages");
      File file = new File(path+"/"+imageFileName);
       if(file.exists()){
    	  file.delete();
       }
}

}
